Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the regular expression escapes for more recent python versions. #343

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

tmolteno
Copy link
Contributor

@tmolteno tmolteno commented Nov 7, 2024

The following syntaxWarnings appear in python 3.12.

scabha/basetypes.py:73: SyntaxWarning: invalid escape sequence '\w'
  match = re.fullmatch("((\w+)://)(.*)", value)

stimela/config.py:275: SyntaxWarning: invalid escape sequence '\$'
  env={key: value.replace('${', '\${') for key, value in os.environ.items()})

scabha/configuratt/resolvers.py:221: SyntaxWarning: invalid escape sequence '\['
  match = re.match("^(.*)\[(.*)\]$", incl)

stimela/backends/kube/__init__.py:198: SyntaxWarning: invalid escape sequence '\['
  event_format:  str = "=NOSUBST('\[k8s event type: {event.type}, reason: {event.reason}] {event.message}')"

scabha/cargo.py:527: SyntaxWarning: invalid escape sequence '\['
  attrs and info.append(f"[dim]\[{rich.markup.escape(', '.join(attrs))}][/dim]")

stimela/kitchen/recipe.py:509: SyntaxWarning: invalid escape sequence '\('
  if re.match('^\(.+\)$', step_spec):

stimela/kitchen/wranglers.py:207: SyntaxWarning: invalid escape sequence '\d'
  elif re.fullmatch('\d+', group):

stimela/commands/run.py:49: SyntaxWarning: invalid escape sequence '\w'
  match2 = re.fullmatch("^([\w.]+)::(.+)$", filename)

stimela/commands/run.py:87: SyntaxWarning: invalid escape sequence '\w'
  match2 = re.fullmatch("^([\w.]+)::(.+)$", filename)

The strings should be raw strings eg, "((\w+)://)(.*)" should become r'((\w+)://)(.*)', otherwise the \w will be treated as an escaped unicode character. Alternatively replace \w with \w.

See here for details.

…he strings should be raw strings eg, "((\w+)://)(.*)" -> r'((\w+)://)(.*)', otherwise the \w will be treated as an excaped unicode character.
Copy link
Member

@o-smirnov o-smirnov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fixes!

@o-smirnov o-smirnov merged commit ace73a7 into caracal-pipeline:master Nov 7, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants